Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Using BUFFER-COPY to assign multiple fields
The
BUFFER-COPYstatement, as the name implies, copies like-named fields from one record buffer to another. You can extend the statement to either include or exclude fields from the copy, and to do other assignments of fields with different names and assignments involving expressions. Here is the syntax of theBUFFER-COPYstatement:
By default, the
BUFFER-COPYstatement copies all like-named fields from thesource-bufferto thetarget-buffer. As with any other assignment, if the data types and extents of the fields are not compatible, an error results. Any fields in thesource-bufferthat don’t have a like-named field in thetarget-bufferare not copied. Likewise, any fields in thetarget-bufferthat don’t have a like-named field in thesource-bufferare ignored. No error results from this mismatch of fields.If you want to copy only certain fields from the
source-buffer, you can do this in one of two ways:Thus, you can use either option depending on which one lets you specify a shorter list of fields for special handling. You might also want to consider future code maintenance in making this choice. If you use the
EXCEPToption, then any fields that you might add in the future to the tables you’re copying will automatically be picked up when you recompile the procedure. If you use theUSINGoption they will not be. The option you choose depends on your reasons for including or excluding fields and on what you want to have happen if the buffer definitions change.In addition to like-named fields, you can do any other kind of assignment from the
source-bufferto thetarget-bufferusing anASSIGNstatement. As with theASSIGNstatements you’ve seen in examples so far, this is basically a list of assignments with thetargetfield on the left side of an equal sign and thesourcefield on the right. You can also include aWHENphrase in an assignment to define a logical expression that determines whether the assignment is done. For more information, see the section for theASSIGNstatement in the online help or in OpenEdge Development: Progress 4GL Reference .As with other statements, the
NO-ERRORkeyword suppresses any error messages that might result from improper assignment and lets you query theERROR-STATUShandle afterwards instead.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |